def calculate_bmi(weight, height):
    # 确保身高单位为米
    if height <= 0:
        raise ValueError("身高必须大于0")

        # 计算BMI
    bmi = weight / (height ** 2)
    return bmi


# 示例使用
weight = float(input("请输入您的体重（kg）："))
height = float(input("请输入您的身高（m）："))

try:
    bmi_result = calculate_bmi(weight, height)
    print(f"您的BMI值为：{bmi_result:.2f}")

    # 可选：根据BMI值给出健康建议
    if bmi_result < 18.5:
        print("您的体重过轻")
    elif 18.5 <= bmi_result < 24:
        print("您的体重正常")
    elif 24 <= bmi_result < 28:
        print("您的体重过重")
    else:
        print("您的体重肥胖")
except ValueError as e:
    print(e)